//
//  DelegateManager.h
//  CLBrowser
//
//  Created by 梁慧聪 on 2017/1/1.
//  Copyright © 2021年 梁慧聪. All rights reserved.
//

#import <Foundation/Foundation.h>

@class CLWebView,CLWebView,CLFindInPageBar;

extern NSString *const kDelegateManagerWebView;
extern NSString *const kDelegateManagerBrowserContainerLoadURL;
extern NSString *const kDelegateManagerFindInPageBarDelegate;

@protocol CLWebViewDelegate <NSObject>

@optional
- (void)webViewDidStartLoad:(CLWebView *)webView;
- (void)webViewDidFinishLoad:(CLWebView *)webView;
- (void)webView:(CLWebView *)webView didFailLoadWithError:(NSError *)error;
- (void)webView:(CLWebView *)webView gotTitleName:(NSString*)titleName;
- (void)webViewForMainFrameDidCommitLoad:(CLWebView *)webView;
- (void)webViewForMainFrameDidFinishLoad:(CLWebView *)webView;
- (void)webView:(CLWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
- (void)webViewForMainFrameDidChangeHtml:(CLWebView *)webView;
- (void)webView:(CLWebView *)webView hiddenTopBar:(BOOL)isHiddenTopBar;
- (void)webView:(CLWebView *)webView hiddenBottomBar:(BOOL)isHiddenBottomBar;
@end


#pragma mark - CLBrowserLoadURLDelegate

@protocol CLBrowserLoadURLDelegate <NSObject>

@optional
//ContainerView Load URL Delegate
- (void)browserContainerViewLoadWebViewWithSug:(NSString *)text;

@end

#pragma mark - FindInPageBarDelegate

@protocol CLFindInPageBarDelegate <NSObject>

@optional
- (void)findInPage:(CLFindInPageBar *)findInPage didTextChange:(NSString *)text;
- (void)findInPage:(CLFindInPageBar *)findInPage didFindPreviousWithText:(NSString *)text;
- (void)findInPage:(CLFindInPageBar *)findInPage didFindNextWithText:(NSString *)text;
- (void)findInPageDidPressClose:(CLFindInPageBar *)findInPage;

@end


@interface CLDelegateManager : NSObject

SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(CLDelegateManager)
- (void)registerDelegate:(id)delegate forKey:(NSString *)key;
- (void)registerDelegate:(id)delegate forKeys:(NSArray<NSString *> *)keys;
- (void)performSelector:(SEL)selector arguments:(NSArray *)arguments key:(NSString *)key;

@end
